package pers.cz.codegen;

import org.junit.Test;
import pers.cz.codegen.codegen.CodeGenerator;
import pers.cz.codegen.template.EntityCodeGenerator;
import pers.cz.codegen.template.ImsBeanCodeGenerator;
import pers.cz.codegen.template.TestTemplate;

/**
 * @program: Jef-code-generator
 * @description:
 * @author: Cheng Zhi
 * @create: 2023-05-11 15:42
 **/
public class Demo1 {

    /**
     * @author Chengzhi
     * @date 2023-05-11
     * @测试目的：使用自定义模板自动生成代码
     * @预期结果:
     */
    @Test
    public void test1() throws Exception {
        CodeGenerator codeGenerator = new ImsBeanCodeGenerator();
        codeGenerator.setFileFolder("target");
        codeGenerator.setIpackage("com.ailk.ims.business.acctinterface.aiH5.collectionFeeMgnt");
        codeGenerator.generateCode();
    }

    /**
     * @author Chengzhi
     * @date 2023-05-11
     * @测试目的：根据数据库配置自动生成代码
     * @预期结果:
     */
    @Test
    public void test2() throws Exception {

        CodeGenerator codeGenerator = new EntityCodeGenerator();
        codeGenerator.setFileFolder("target");
        codeGenerator.setIpackage("pers.cz.test");
        codeGenerator.generateCode();
    }

    /**
     * @author Chengzhi
     * @date 2023-08-13
     * @测试目的： 带有内部类的代码生成
     * @预期结果:
     */
    @Test
    public void test3() throws Exception {

        TestTemplate testTemplate = new TestTemplate();
        testTemplate.setFileFolder("target");
        testTemplate.setIpackage("pers.cz.test");
        testTemplate.generateCode();
    }

    /**
     * @author Chengzhi
     * @date 2023-08-31
     * @测试目的： 测试字符串分割
     * @预期结果:
     */
    @Test
    public void testSplit(){

        String tableName = "SD.SYS_PARAMETER";
        String[] split = tableName.split("\\.");
        System.out.println(split.length);

        String[] splitOld = tableName.split(".");
        System.out.println(splitOld.length);
    }
}
